<template>
  <div>
    <el-popover placement="right" width="400" trigger="click">
      <el-form :label-position="labelPosition" label-width="80px">
        <el-form-item label="用户名">
          <el-input
            style="width: 300px"
            placeholder="请输入用户名"
            v-model="stu_name"
          ></el-input>
        </el-form-item>
        <el-form-item label="年龄">
          <el-input
            style="width: 300px"
            placeholder="请输入年龄"
            v-model="stu_age"
          ></el-input>
        </el-form-item>
        <el-form-item label="性别">
          <el-input
            style="width: 300px"
            placeholder="请输入性别"
            v-model="stu_gender"
          ></el-input>
        </el-form-item>
        <el-form-item label="个性签名">
          <el-input
            style="width: 300px"
            placeholder="请输入个性签名"
            v-model="stu_sign"
          ></el-input>
        </el-form-item>
      </el-form>
      <el-button style="margin-left: 180px" @click="revise">确认修改</el-button>
      <el-button slot="reference" type="text" size="small">修改</el-button>
    </el-popover>
  </div>
</template>

<script>
export default {
  data() {
    return {
      labelPosition: "right",
      stu_name: "",
      stu_age: "",
      stu_gender: "",
      stu_sign: "",
    };
  },
  props: ["stu_id"], //接受父组件传递的值
  methods: {
    //修改操作
    revise() {
      let stu_id = this.stu_id; //用户id
      let user = this.stu_name; //用户名
      let age = this.stu_age; //用户年龄
      let sex = this.stu_gender; //用户性别
      let geqian = this.stu_sign; //用户个性签名
    const params = `stu_id=${stu_id}&user=${user}&age=${age}&sex=${sex}&geqian=${geqian}`
    console.log(params)
      let url = "http://localhost:8080/user/regUpdata";
      this.axios
        .post(url, params)
        .then((res) => {
          console.log(res);
          if(res.data.code==200){
              this.$router.go(0)//刷新当前页面
          }
        });
    },
  },
};
</script>

<style lang="scss" scoped></style>
